home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************
- * atoi.c - much smaller than unix & stdio libraries
- *
- * WN Rausch
- * January 1987
- **********************************************************************/
-
- #include <MacTypes.h>
- #include <pascal.h>
- #include <strings.h>
-
- #define isspace(c) (c == ' ' || c == '\t')
- #define ZERO 48
-
- /**********************************************************************/
- atoi(string)
- register char *string; /* must be NULL terminated */
- {
- register long answer = 0L;
- Boolean negative = FALSE;
-
- while (isspace(*string))
- string++;
-
- if (*string == '-')
- negative = TRUE;
-
- while (*string)
- {
- answer = (answer * 10) + (*string - ZERO);
- string++;
- }
-
- if (negative)
- answer = 0 - answer;
-
- return (int)answer;
- }